using LitJson;
using System;
using UnityEngine;

public class UnityGameObjectReceiver : MonoBehaviour
{
	private string _log;

	public string logInfo => _log;

	public void OnBillingSupported(string message)
	{
		BillingLog("OnBillingSupported: " + message);
	}

	public void OnPurchaseStateChange(string message)
	{
		BillingLog("OnPurchaseStateChange: " + message);
	}

	public void OnRequestPurchaseResponse(string message)
	{
		BillingLog("OnRequestPurchaseResponse: " + message);
	}

	public void OnRestoreTransactionsResponse(string message)
	{
		BillingLog("OnRestoreTransactionsResponse: " + message);
	}

	public void OnPurchaseResponse(string message)
	{
		BillingLog("OnPurchaseResponse: " + message);
		PurchaseInfo purchaseInfo = JsonMapper.ToObject<PurchaseInfo>(message);
		AndroidPurchases.UpdatePurchase(purchaseInfo);
	}

	public void OnError(string message)
	{
		BillingLog("OnError: " + message);
	}

	private void BillingLog(string logInfo)
	{
		_log = logInfo + Environment.NewLine + _log;
	}
}
